package com.pig4cloud.pigx.contract.api.v1.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.contract.dto.ContractOrderCloseDTO;
import com.pig4cloud.pigx.contract.dto.ContractOrderCloseMarketDTO;
import com.pig4cloud.pigx.contract.dto.ContractOrderOpenDTO;
import com.pig4cloud.pigx.contract.entity.ContractOrder;
import com.pig4cloud.pigx.contract.open.api.dto.OpenApiOrderBookDTOV1;
import com.pig4cloud.pigx.contract.open.api.vo.OpenApiOrderBookVOV1;
import com.pig4cloud.pigx.contract.open.api.vo.OpenApiOrderVOV1;
import com.pig4cloud.pigx.contract.vo.ContractOrderInitResVO;

import java.util.List;

/**
 */
public interface OrderServiceV1 extends IService<ContractOrder> {

    /**
     * 获取用户当前挂单 - 币对
     *
     * @param symbolName 币对名称
     * @return 挂单list
     */
    R<List<OpenApiOrderVOV1>> getUserNowOrderBySymbol(String symbolName);

    /**
     * 获取用户当前所有挂单
     *
     * @return 挂单list
     */
    R<List<OpenApiOrderVOV1>> getUserNowOrder();

    /**
     * 查询订单详情
     *
     * @param condition 查询条件
     * @return {@link OpenApiOrderVOV1}
     * @since 2023/1/9 19:19
     */
    OpenApiOrderVOV1 getOrder(ContractOrder condition);

    /**
     * 撤销单个订单
     *
     * @param id id
     * @return r
     */
    R cancel(Long id);


    /**
     * 撤销当前用户全部订单
     *
     * @return r
     * @since 2022/9/3 21:40
     */
    R cancelAll();

    /**
     * 开仓
     *
     * @param dto dto
     * @return {@link R< ContractOrderInitResVO>}
     * @since 2022/8/16 18:08
     */
    R<ContractOrderInitResVO> open(ContractOrderOpenDTO dto);

    /**
     * 平仓
     *
     * @param dto dto
     * @return {@link R< ContractOrderInitResVO>}
     * @since 2022/9/6 14:38
     */
    R<ContractOrderInitResVO> close(ContractOrderCloseDTO dto);

    /**
     * 市价全平
     *
     * @param dto dto
     * @return {@link ContractOrderInitResVO}
     * @since 2023/2/28 16:22
     */
    ContractOrderInitResVO closeMarket(ContractOrderCloseMarketDTO dto);

    /**
     * 获取最优订单
     *
     * @param dto dto
     * @return r
     */
    R<OpenApiOrderBookVOV1> getOrderBook(OpenApiOrderBookDTOV1 dto);
}
